package com.hackintosh.state.extend;

import java.util.HashMap;
import java.util.Map;

/**
 * @description：
 * @author：twislyn
 * @date：Created in 2021/05/23
 * @modified By：
 * @version: 1.0
 */
public class ShareContext {
    private ShareState state;
    private Map<String,ShareState> stateMap = new HashMap<>();

    public ShareState getState(String key) {
        ShareState shareState = stateMap.get(key);
        return shareState;
    }

    public void setState(ShareState state) {
        this.state = state;
    }

    public ShareContext() {
        state = new ConcreteState1();
        stateMap.put("1",state);
        state = new ConcreteState2();
        stateMap.put("2",state);
        state = stateMap.get("1");
    }

    public void handle(){
        state.handle(this);
    }
}
